﻿using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using GIMS.Def.Arguments;
using GIMS.Def.Flags;
using GIMS.Def.Settings;

namespace GIMS.Def.Operators
{
    public class AppendOperator : Operator
    {
        private GravitySetting gravitySetting;
        private BackgroundSetting backgroundSetting;

        public AppendOperator()
        {
            name = "Append";
            description = "Joins images horizontally or vertically";
            instruction = "append";
            iconPath = @"Images\append.png";
            argument = new AppendArgument();
            possiblePrograms = Program.convert;
            position = Position.Between;
            gravitySetting = new GravitySetting();
            gravitySetting.Description = "Positioning of images relative to other ones";
            backgroundSetting = new BackgroundSetting();
            backgroundSetting.Description = "If the images are not of the same size, narrower images are padded with this color";
            settings = new List<Setting> { gravitySetting, backgroundSetting };
            expectsMultipleInputs = true;

            argument.PropertyChanged += new PropertyChangedEventHandler(OnArgumentChanged);
            gravitySetting.Argument.PropertyChanged += new PropertyChangedEventHandler(OnArgumentChanged);  
            backgroundSetting.Argument.PropertyChanged += new PropertyChangedEventHandler(OnArgumentChanged);
            gravitySetting.PropertyChanged += new PropertyChangedEventHandler(OnSettingChanged);
            backgroundSetting.PropertyChanged += new PropertyChangedEventHandler(OnSettingChanged);

            #region Optional: set some default Argument-Values and/or Setting-Argument-Values

            ((ColorArgument) backgroundSetting.Argument).Color = Color.White;

            #endregion

        }

        protected override string CreateOperatorScript()
        {
            return string.Concat(argument.CreateScriptPart(), instruction);
        }
    }
}
